package com.example.exportPdf;

import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ToPdf {
    public static void main(String[] args) {
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("name","张三");
        map.put("age","18");
        map.put("sex","男");
        Map<String,Object> map1 = new HashMap<>();
        map1.put("name","李四");
        map1.put("age","19");
        map1.put("sex","女");
        list.add(map);
        list.add(map1);
        String[] headers = new String[]{"姓名","年龄","性别"};
        String[] fields = new String[]{"name","age","sex"};
        try {
            FileOutputStream outputStream = new FileOutputStream("C:\\Users\\hyh92\\Desktop\\test.pdf");
            PdfGenerator.generatePdf(list,"用户信息表",headers,fields,outputStream);
            outputStream.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
